<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* ************* call ************* */
        function fn(x, y) {
            console.log('function.... ', this === o, x, y);
        }
        const o = {
            objFn: fn
        };
        fn(); // window
        o.objFn(); // o
        fn.call(o, 1, 2); // o

        /* ************* 继承属性 ************* */
        console.log('************* 继承属性 *************');

        function Father(uname, age) {
            this.uname = uname;
            this.age = age;
        }
        Father.prototype.sayHi = function(name) {
            console.log('hello, ' + name);
        }

        function Son(uname, age, score) {
            Father.call(this, uname, age);
            this.score = score;
        }

        let son = new Son('s', 12, 100);
        console.log(son);

        /* ************* 继承方法 ************* */
        console.log('************* 继承方法 *************');
        const f = new Father();
        Son.prototype = f;
        Son.prototype.constructor = Son;
        Son.prototype.exam = function() {
            console.log('我去考试了。');
        }
        son = new Son('s', 12, 100);
        console.log(son);
        console.log(new Father());
        console.log(son.__proto__ === f);
        son.sayHi();
        son.exam();
    </script>
</body>

</html>